package com.example.hospital.controller;

import com.example.common.util.core.controller.BaseController;
import com.example.common.util.core.resultbody.AjaxResult;
import com.example.hospital.service.ScheduleService;
import com.example.model.domain.entity.hospital.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author juzipi
 * @Date 2021/7/13 11:23
 * @Info
 */
@Api(tags = "排班管理")
@RestController
@RequestMapping("admin/hospital/schedule")
public class ScheduleController extends BaseController {

    @Autowired
    private ScheduleService scheduleService;


    //根据医院编号 和 科室编号 ，查询排班规则数据
    @ApiOperation(value ="查询排班规则数据")
    @GetMapping("get/scheduleRule/{pageNum}/{pageSize}/{hoscode}/{depcode}")
    public AjaxResult getScheduleRule(
            @PathVariable Long pageNum,
            @PathVariable Long pageSize,
            @PathVariable String hoscode,
            @PathVariable String depcode
    )
    {
        Map<String,Object> map = scheduleService.getScheduleRule(pageNum,pageSize,hoscode,depcode);
        return AjaxResult.success(map);
    }


    @ApiOperation("查询排班的详情信息")
    @GetMapping("get/scheduleDetail/{hoscode}/{depcode}/{workDate}")
    public AjaxResult getSchedule(@PathVariable String hoscode, @PathVariable String depcode, @PathVariable String workDate){
        List<Schedule> scheduleDetails = scheduleService.getScheduleDetails(hoscode, depcode, workDate);
        return AjaxResult.success(scheduleDetails);
    }


}
